import 'package:json_annotation/json_annotation.dart';
import 'package:mall/core/models/delivery_status.dart';
import 'package:mall/core/models/order_status.dart';

import 'jump_type.dart';

part 'order_checkout.g.dart';

@JsonSerializable()
class OrderCheckout {
  // 是否需要继续第三方支付。如果是纯积分支付则为false，如果有人民币参与支付则为true
  final bool pay;

  // 第三方支付签名信息
  final dynamic sign;

  // 支付模式。只能是支付宝或微信支付二者之一
  // FREE, JF_PAY, WX_PAY, ALI_PAY
  final PayMode payMode;

  // 支付后APP应显示的目标UI
  // JUMP_EMPTY, JUMP_IN_STORE, JUMP_IN_STORE_AREA, JUMP_IN_PRODUCT_CATALOG, JUMP_IN_MY_STORE, JUMP_IN_PRODUCT, JUMP_IN_PRODUCT_SEARCH, JUMP_IN_STORE_SEARCH, JUMP_IN_ORDER_LIST, JUMP_IN_PIN_GOU_HISTORIES
  final JumpType jumpType;

  // 订单状态 UNPAID, PAYING, PAID, CANCELLED
  final OrderStatus orderStatus;

  // 快递状态 NONE, PARTIALLY, CONFIRMING, CONFIRMED
  final DeliveryStatus deliveryStatus;

  OrderCheckout(
    this.pay,
    this.sign,
    this.payMode,
    this.jumpType,
    this.orderStatus,
    this.deliveryStatus,
  );

  factory OrderCheckout.fromJson(Map<String, dynamic> json) => _$OrderCheckoutFromJson(json);

  Map<String, dynamic> toJson() => _$OrderCheckoutToJson(this);
}

/// 支付方式
enum PayMode {
  FREE,
  JF_PAY,
  WX_PAY,
  ALI_PAY,
}
